package org.learn.intermediate.homework;

public class HomeWork06 {
    public static void main(String[] args) {
        Cellphone cellphone = new Cellphone();
        cellphone.testWork(new Calculate() {
            @Override
            public double work(double n1, double n2) {
                return n1 + n2;
            }
        },10,8);
    }
}
interface Calculate{
    public double work(double n1 , double n2) ;
}
class Cellphone {
    //当我们调用testWork方法的时候，直接传入一个实现了Calculate的匿名内部类
    public void testWork(Calculate calculate, double n1 , double n2){
        double result = calculate.work(n1, n2);
        System.out.println("计算结果是" + result);
    }
}